﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var auditData = Jxstar.findComboData('audit');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var authtypeData = Jxstar.findComboData('authtype');
	var purtype2Data = Jxstar.findComboData('purtype2');
	var orgtypeData = Jxstar.findComboData('orgtype');

	var cols = [
	{col:{header:'记录状态', width:81, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: auditData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: auditData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < auditData.length; i++) {
				if (auditData[i][0] == value)
					return auditData[i][1];
			}
		}}, field:{name:'pur_apply_chk__auditing',type:'string'}},
	{col:{header:'采购单号', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__apply_code',type:'string'}},
	{col:{header:'项目编号', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__project_code',type:'string'}},
	{col:{header:'项目名称', width:222, sortable:true}, field:{name:'pur_apply_chk__project_name',type:'string'}},
	{col:{header:'项目类别', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'pur_apply_chk__money_type',type:'string'}},
	{col:{header:'授权形式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: authtypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: authtypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < authtypeData.length; i++) {
				if (authtypeData[i][0] == value)
					return authtypeData[i][1];
			}
		}}, field:{name:'pur_apply_chk__auth_type',type:'string'}},
	{col:{header:'拟采取招标方式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: purtype2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: purtype2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < purtype2Data.length; i++) {
				if (purtype2Data[i][0] == value)
					return purtype2Data[i][1];
			}
		}}, field:{name:'pur_apply_chk__pur_type',type:'string'}},
	{col:{header:'拟采取组织形式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: orgtypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: orgtypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < orgtypeData.length; i++) {
				if (orgtypeData[i][0] == value)
					return orgtypeData[i][1];
			}
		}}, field:{name:'pur_apply_chk__org_type',type:'string'}},
	{col:{header:'预算金额(万元)', width:112, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'pur_apply_chk__project_money',type:'float'}},
	{col:{header:'实施单位', width:100, sortable:true}, field:{name:'pur_apply_chk__dept_name',type:'string'}},
	{col:{header:'项目批复文号', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__check_fileno',type:'string'}},
	{col:{header:'项目批复名称', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__check_name',type:'string'}},
	{col:{header:'主管部门', width:100, sortable:true}, field:{name:'pur_apply_chk__done_deptname',type:'string'}},
	{col:{header:'项目负责人', width:88, sortable:true}, field:{name:'pur_apply_chk__project_user',type:'string'}},
	{col:{header:'申请人', width:78, sortable:true}, field:{name:'pur_apply_chk__apply_user',type:'string'}},
	{col:{header:'申请日期', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'pur_apply_chk__apply_date',type:'date'}},
	{col:{header:'项目主要内容（含标段划分、实施周期及概算造价等）', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__project_content',type:'string'}},
	{col:{header:'公告发布媒体选择', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__pur_type_mt',type:'string'}},
	{col:{header:'招标公告审核', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__pur_type_gg',type:'string'}},
	{col:{header:'拟邀单位及理由', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__pur_type_dw',type:'string'}},
	{col:{header:'投标邀请书审核', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__pur_type_yqs',type:'string'}},
	{col:{header:'代理机构名称', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__org_type_proxy',type:'string'}},
	{col:{header:'委托理由', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__org_type_wt',type:'string'}},
	{col:{header:'招标活动计划安排', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__active_plan',type:'string'}},
	{col:{header:'评委组成(人数、专业、产生办法)', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__checker_comp',type:'string'}},
	{col:{header:'标底或拦标价编制情况（自行或委托编制）', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__base_price',type:'string'}},
	{col:{header:'项目ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__project_id',type:'string'}},
	{col:{header:'采购单ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__apply_id',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__apply_chkid',type:'string'}},
	{col:{header:'实施单位ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__dept_id',type:'string'}},
	{col:{header:'项目负责人ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__project_userid',type:'string'}},
	{col:{header:'申请人ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__apply_userid',type:'string'}},
	{col:{header:'投资计划编号', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__plan_code',type:'string'}},
	{col:{header:'投资计划ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__plan_id',type:'string'}},
	{col:{header:'主管部门ID', width:100, sortable:true, hidden:true}, field:{name:'pur_apply_chk__done_deptid',type:'string'}},
	{col:{header:'批复金额(万元)', width:100, sortable:true, hidden:true, renderer:JxUtil.formatNumber(6)}, field:{name:'pur_apply_chk__plan_money',type:'float'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '0',
		isshow: '1',
		funid: 'pur_apply_chk'
	};
	
	
	config.eventcfg = {						//创建新采购单		createPurApply: function(){			var records = this.grid.getSelectionModel().getSelections();			if (!JxUtil.selectone(records)) return;			var apply_auditing = records[0].get('pur_apply_chk__auditing');			if( !(apply_auditing =='1' || apply_auditing == '3')){				JxHint.alert('采购方案还未审批通过，不能创建新采购单！');					return false;			}						var self = this;			//取选择记录的主键值			var params = 'funid='+ self.define.nodeid;			for (var i = 0; i < records.length; i++) {				params += '&keyid=' + records[i].get(self.define.pkcol);			}			//设置请求的参数			params += '&pagetype=grid&eventcode=createPurApply';						//执行处理的内容			var endcall = function(data) {				//重新加载数据				self.grid.getStore().reload();			};			//发送请求			Request.postRequest(params, endcall);		}			
};
		
	return new Jxstar.GridNode(config);
}